/*找到最长的单词并返回长度*/
/*method1:*/
function findLongestWord(str) {
  let arr=str.split(' ');
  arr.sort(function (a,b) {
    return b.length-a.length;
  });
  return arr[0].length;
}

/*method2:*/
function findLongestWord(str){
  let arr=str.split(' ');
  let res=0;
  for(let i=0;i<arr.length;i++){
    if(res<arr[i].length){
      res=arr[i].length;
    }
  }
  return res;
}

console.log(findLongestWord("The quick brown fox jumped over the lazy dog"));
